<template>
	<view class="integral_cont">
		<view class="int-text">我的积分:<text class="text">{{integralnum}}</text> </view>
		<view class="integral_item" v-for="(item,index) in tegData" :key="index">
			<view class="type_text" :class="item.integral>0?'qian':'ding'">
				{{item.integral>0?'签':'订'}}
			</view>
			<view class="cont">
				<view class="top">
					<view class="text">
						{{item.source}}
					</view>
					<view class="num">
						{{item.integral>0?'+'+item.integral:item.integral}}
					</view>
					
				</view>
				<view class="bottom">
					<view class="text">
						{{item.integral>0?'签到获得':'订阅使用'}} 
					</view>
					<view class="time">
						{{item.created_at}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {accumlateinfo,useraCcumulate} from '@/api/site.js'
	export default {
		data() {
			return {
				integralnum:0,
				page:1,
				tegData:[],
				integral:''
			};
		},
		onLoad() {
			this.getaccumlateinfo()
		},
		methods:{
			getaccumlateinfo(){
				accumlateinfo({page:1}).then(res=>{
					this.tegData=res.data
					// let num=this.tegData.length
					// for(let i=0;i<num;i++){
					// 	this.integralnum+= parseInt(this.tegData[i].integral) 
					// }
				})
				useraCcumulate().then(res=>{
					let {accumulate_points}=res.data.member
					this.integralnum=accumulate_points
			})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.integral_cont{
		padding: 20px 15px;
		.int-text{
			.text{
				color:#2979ff;
			}
		}
	}
	.integral_item{
		display: flex;
		justify-content: space-between;
		background-color: #fff;
		padding: 8px;
		margin-top: 20px;
		.type_text{
			width: 70px;
			height: 70px;
			font-size: 30px;
			font-weight: bold;
			color: #fff;
			text-align: center;
			line-height: 70px;
			margin-right: 10px;
		}
		.qian{
			background-color:#FE462C ;
		}
		.ding{
			background-color:#3CAFFF;
		}
		.cont{
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.top{
				display: flex;
				justify-content: space-between;
				align-items: center;
					font-size: 14px;
				.text{
				}
				.num{
					color: #DE6129;
				}
			}
			.bottom{
				display: flex;
				justify-content: space-between;
				align-items: center;
				color: #D6D6D6;
				font-size: 12px;
				.text{
					border:1rpx solid #D6D6D6;
					border-radius: 5px;
					padding: 1px 2px;
				}
				.time{
					
				}
			}
		}
	}
</style>
